<?php
session_start();
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";

$CboNodo = $_REQUEST["CboNodo"];
$CboModulo = $_REQUEST["itemselec"];

switch($_REQUEST["opc"]) {
    case "M":
        $imagen = "iconos/soloico_grabar.gif";
        $etiqueta="Grabar Opci&oacute;n";
        $oculto="<input type='hidden' name='opc' value='M'>";
        $titulo="Modificar Opci&oacute;n";
        $CboDisabled = true;
        $readonly="readonly='true'";
        break;
    case "E":
        $imagen = "iconos/soloico_eliminar.gif";
        $etiqueta="Eliminar Opci&oacute;n";
        $oculto="<input type='hidden' name='opc' value='E'>";
        $titulo="Eliminar Opci&oacute;n";
        $CboDisabled = true;
        $readonly="readonly='true'";
        break;
    case "I":
        $imagen = "iconos/soloico_grabar.gif";
        $etiqueta="Grabar Opci&oacute;n";
        $oculto="<input type='hidden' name='opc' value='I'>";
        $titulo="Ingresar Opci&oacute;n";
        //'CboDisabled=true
        $readonly="readonly='true'";
        break;
}

//'''TopNodo=1
//'''if CboNodo = "" then CboNodo = TopNodo	'si es blanco le asigno el primer valor
SoloFun_ExecSql ("select * from solotb_nivel1", $SoloArrNodos);
$StrCboNodo = SoloFun_CargaCombo($SoloArrNodos,"CboNodo","$CboDisabled",$CboNodo," class='SoloStyle_Texto' style='width:200'","");
if($CboDisabled)
    $StrCboNodo .= "<input type=\"hidden\" name=\"CboNodo\" value=\"$CboNodo\"/>";

$strSql = "select * from solotb_modulo where nodo= $CboNodo order by ds_modu";

SoloFun_ExecSql ($strSql, $ArrModu);
//'rw"",CboModulo
$itemselec = $CboModulo;
//'response.write(itemselec)
//'response.End()
$StrCboModulo = SoloFun_CargaCombo($ArrModu,"CmbModulo","$CboDisabled",$itemselec," class='SoloStyle_Texto' style='width:200'","");

if($CboDisabled)
    $StrCboModulo .= "<input type=\"hidden\" name=\"CmbModulo\" value=\"$itemselec\"/>";

//'response.write "<br>OPC = " & $_REQUEST["opc")
//'response.write "<br>CboNodo = " & $_REQUEST["CboNodo")& "<br>"
//'response.end
//'StrCboNodo = Cargar_nodosql(CboNodo, "CboNodo", "")
//'   On error resume next
//
//'rw "",$_REQUEST["hidid2")
//'rw "",$_REQUEST["opc")

$xtxtOrden = $_REQUEST["xtxtOrden"];

if ($_REQUEST["HidId2"] <> "") {
//''''	 xtxtOrden = $_REQUEST["xtxtOrden")
//	 '''if $_REQUEST["chkNoMostrar")="on" then nomostrar = 1
//	 'rw "",$_REQUEST["opc")
//	 're
    $tabla = "solotb_modulo_transaccion";
    switch($_REQUEST["opc"]) {
        case "M":
            $tipo = "UPDATE";
            $strSql = "$tipo $tabla set ";
            $strSql .= "co_tran=" . $_REQUEST["HidId2"] . ",";
            $strSql .= "ds_tran='" . $_REQUEST["TxtDesc"] . "',";
            $no_prog = str_replace("|","'",$_REQUEST["AtxtProg"]);
            $strSql .= "no_prog='" . $no_prog . "',";
            $strSql .= " nomostrar='" . $xtxtOrden  ."'";
            $strSql .= " where co_modu=" . $_REQUEST["id1"];
            $strSql .= "  and nodo=" . $CboNodo;
            $strSql .= "  and co_tran=" . $_REQUEST["HidId2"];
            //'response.write strSql
            //	 'response.End()
            break;
        case "E":
            $tipo = "DELETE";
            $strSql = "$tipo from $tabla ";
            $strSql .= "where co_modu=" . $_REQUEST["id1"];
            $strSql .= "  and nodo=" . $CboNodo;
            $strSql .= "  and co_tran=" . $_REQUEST["HidId2"];
//		 'response.write strSql
//'		 response.End()
            break;
        case "I":
            $no_prog = str_replace("'","|", $_REQUEST["AtxtProg"]);
            $tipo = "INSERT";
            $strSql = "$tipo into $tabla values (";
//'''	     $strSql .= $_REQUEST["CmbModulo") & "," se remplazo por id1
            $strSql .= $_REQUEST["id1"] . ",";
            $strSql .= $_REQUEST["HidId2"]    . ",'";
            $strSql .= $_REQUEST["TxtDesc"]  . "','";
            $strSql .= $no_prog  . "',";
            $strSql .= $_REQUEST["CboNodo"] . ",";
            $strSql .= "'$xtxtOrden')";
//		 'rw "",strSql
//		 're
            break;
    }

    $arrQueries = array();
    array_push($arrQueries, $strSql);
    array_push($arrQueries, crearQueryLog($tabla, $tipo, $strSql));
    $oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"], 
            $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
    //if(!$oConexion->EjecutarQuery($strSql)) {
    if(!$oConexion->EjecutarTransaccion($arrQueries)) {
        $strMsg = "solotrn_GrabarTransaccion.php?SoloError=1&CmbModulo=". $_REQUEST["id1"] . "&CboNodo=".$_REQUEST["CboNodo"]."&opc=".$_REQUEST["opc"]."&id2=".$_REQUEST["HidId2"]."&ds1=".$_REQUEST["TxtDesc"]."&ds2=".$_REQUEST["AtxtProg"]. "&itemselec=" . $_REQUEST["id1"];
//echo $strSql;
//        echo $oConexion->getErrorMessage();
    }else {
        $strMsg = "solotrn_GrabarTransaccion.php?SoloError=0&CmbModulo=". $_REQUEST["id1"] . "&CboNodo=".$_REQUEST["CboNodo"]."&opc=".$_REQUEST["opc"]."&id2=".$_REQUEST["HidId2"]."&ds1=".$_REQUEST["TxtDesc"]."&ds2=".$_REQUEST["AtxtProg"]. "&itemselec=" . $_REQUEST["id1"]. "&xtxtOrden=" . $_REQUEST["xtxtOrden"];
//		 'rw "",strmsg
//	  're
    }
    $oConexion->Cerrar();
//'	  response.write "<br>strMsg="&strMsg
//'	  response.end
    header("Location: $strMsg");
}


//'rw "",$_REQUEST["id1")
//'re
$strSql = "select ds_modu from solotb_modulo where nodo= 1";
if ($_REQUEST["id1"]<>"") {
    $strSql .= " and  co_modu=" . $_REQUEST["id1"];
}
//   'response.write strSql
//   'response.end
$err = 0;
$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"], 
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
if(!$oConexion->EjecutarQuery($strSql)) {
    $strERROR = 1;
    $err = 0;
}else {
    $arrdsModu = $oConexion->getData("NUM");
    $Desc = $arrdsModu[0][0];
}
?>
<html>
    <head>
        <title>MIES - WORKFLOW - Transacci&oacute;n</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
        <SCRIPT type="text/JavaScript" src="Includes/Solofun_generales.js"></SCRIPT>
    </head>

    <body topmargin=0 leftmargin=0>
        <img src="templates/SoloTemplate_LogoCabecera.png" style="height: 50px"/>
        <p align="center" class="SoloStyle_TituloPaginas"><?php echo $titulo;?></p>
        <form name="frm" action="solotrn_GrabarTransaccion.php" method="POST">
            <?php echo $oculto;?>
            <table border="0" width="80%" align="center" cellpadding="2" cellspacing="1" bordercolor="#CCCCCC">
                <tr>
                    <td><img src="iconos/soloico_salir.gif" border="1" alt="Regresar" style="cursor:hand" onClick="window.opener.location.reload(); window.close();" > <img src="<?php echo $imagen;?>" border="1" alt="<?php echo $etiqueta;?>" style="cursor:hand" onClick="frm.submit();"></td>
            </table>
            <table border="0" width="80%" align="center" bordercolor="#CCCCCC" cellpadding="2" cellspacing="2">

                <tr >
                    <td class="SoloStyle_Etiqueta" width="30%">Subsecretar&iacute;a/Dir. Provincial</td>
                    <td class="SoloStyle_EtiquetaCajas" width="70%"><?php echo $StrCboNodo; ?></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta"><b>M&oacute;dulo</b></td>
                    <td class="SoloStyle_EtiquetaCajas"><?php echo $StrCboModulo;?>
                        <input type="hidden" maxlength="50" size="30" name="id1" class="texto" value="<?php echo $_REQUEST["id1"];?>"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta"><b>Transacci&oacute;n</b></td>
                    <td class="SoloStyle_EtiquetaCajas">
                        <input type='text' maxlength='50' size='30' name='HidId2' class='SoloStyle_Texto' value="<?php echo $_REQUEST["id2"];?>" <?php echo $readonly;?>> </td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Descripci&oacute;n</td>
                    <td class="SoloStyle_EtiquetaCajas">
                        <input type="text" class="SoloStyle_Texto" name="TxtDesc" size="30" maxlength="50" value="<?php echo $_REQUEST["ds1"];?>"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta">Programa Asociado</td>
                    <td class="SoloStyle_EtiquetaCajas">
                        <input name="AtxtProg" <?php  //'If $_REQUEST["nmost") Then response.write "disabled" ?> type="text" class="SoloStyle_Texto" id="AtxtProg" size="30" maxlength="70" value="<?php echo str_replace("|","'", $_REQUEST["ds2"]);?>">
                        <!--&nbsp;&nbsp;<a href="javascript:SoloFun_Windows('SoloContent/SoloContent_AssetLink.php',200,200,350,220,'Asociar')">Asociar P&aacute;gina</a>--></td>
                </tr>
                <td class="SoloStyle_Etiqueta">Orden</td>
                <td class="SoloStyle_EtiquetaCajas"><input name="xtxtOrden" type="text" class="SoloStyle_Texto" size="30" maxlength="50" value="<?php echo $xtxtOrden;?>"></td>
            </table>
        </form>

    </body>
</html>
<?php
include "Includes/soloFun_ShowMessages.php";
?>